package cn.iocoder.mall.resource.service.impl;


import cn.iocoder.mall.resource.dao.ShopTypeMapper;
import cn.iocoder.mall.resource.dataobject.ShopType;
import cn.iocoder.mall.resource.service.IShopTypeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 商品类目/商户类型
 * @Author: jeecg-boot
 * @Date:   2019-10-30
 * @Version: V1.0
 */
@Service
public class ShopTypeServiceImpl extends ServiceImpl<ShopTypeMapper, ShopType> implements IShopTypeService {

    @Resource
    private ShopTypeMapper shopTypeMapper;

    @Override
    public IPage<ShopType> list(Page<ShopType> page, QueryWrapper<ShopType> queryWrapper) {
        return shopTypeMapper.getNodeTree(page,queryWrapper.getCustomSqlSegment());
    }

    @Override
    public List<ShopType> getShopTypeList(Integer type) {
        return shopTypeMapper.getShopTypeList(type);
    }

    @Override
    public List<ShopType> getShopTypeListByName(String name) {
        return shopTypeMapper.getShopTypeListByName(name);
    }

    @Override
    public List<ShopType> getShopTypeListByTypeAndLevel(Integer type, Integer level) {
        QueryWrapper<ShopType> queryWrapper=new QueryWrapper<>();
        ShopType query=new ShopType();
        query.setLevel(level);
        query.setType(type);
        return shopTypeMapper.selectList(queryWrapper);
    }


    @Override
    public List<ShopType> getShopTypeListByParentId(Integer id) {

        QueryWrapper<ShopType> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("parent_id",id);

        return shopTypeMapper.selectList(queryWrapper);

    }

    @Override
    public List<ShopType> getShopTypeListOfNoTree(Integer i) {
        return shopTypeMapper.getShopTypeListOfNoTree(i);
    }

}
